local ld = {}
local U = require "packages/utility/utility"

Fk:addQmlMark{
  name = "lay",
  how_to_show = function(_, value)
    if not value then return ' ' end
    return string.format('%d/%d-%d-%d', value.mp, value.maxMp, #value.trick, #value.equip)
  end,
  qml_path = "packages/brokenroyal/lieding"
}

--target.room:setPlayerMark(target, "@[lay]lay", { owner = target.id, mp = 4, maxMp = 5, trick = {1,2}, shown_trick = {1}, equip = {13,55}, })
--target.room:setBanner("@[lay]lay", { owner = target.id, mp = 4, maxMp = 5, trick = {1,2}, shown_trick = {1}, equip = {13,55}, })

ld.upgradelayer = function(target)
  local mp = target:getMark("instruction")
  local maxmp = target:getMark("maxinstruction")
  local trick = target:getPile("#scenario&")
  if #target:getPile("#scenario") > 0 then
    table.insertTable(trick, target:getPile("#scenario"))
  end
  local shown = target:getPile("#scenario")
  local standby = target:getPile("#standby")
  target.room:setPlayerMark(target, "@[lay]lay", { owner = target.id, mp = mp, maxMp = maxmp, trick = trick, shown_trick = shown, equip = standby, })
end

ld.addinstruction = function(target, n)
  local num = target:getMark("instruction") + n
  num = math.min(num, target:getMark("maxinstruction"))
  if target:getMark("@@tieqi_buff") > 0 then
    num = math.min(num, 1)
  end
  num = math.max(num, 0)
  target.room:setPlayerMark(target, "instruction", num)
  --target.room:setPlayerMark(target, "@instruction", num.."/"..target:getMark("maxinstruction"))
  ld.upgradelayer(target)
end

ld.hasinstructionfortrick = function(target, n)
  local num = n
  if target:getMark("mouduan-phase") > 0 then num = 1 end
  if target:getMark("secretadvance-phase") > 0 then
    num = math.max(n - 2, 0)
  end
  return target:getMark("instruction") >= num
end

ld.costinstructionfortrick = function(target, n)
  local num = n
  if target:getMark("mouduan-phase") > 0 then
     num = 1 
     target.room:setPlayerMark(target, "mouduan-phase", 0)
  end
  if target:getMark("secretadvance-phase") > 0 then
    num = math.max(n - 2, 0)
    target.room:setPlayerMark(target, "secretadvance-phase", 0)
  end
  if num > 0 then
    ld.addinstruction(target, -num)
  end
end

ld.hasTrickforuse = function(target, name)
  if not target:getPile("#scenario&") then return false end
  if #target:getPile("#scenario&") > 0 then
    return table.find(target:getPile("#scenario&"), function(id) return Fk:getCardById(id).name == name end)
  end
  return false
end
--方针与毒计
ld.invokePolicyorTrap = function(player, name)
  player.room:sendLog{
    type = "#invokepolicy",
    from = player.id,
    arg = name,
    toast = true,
  }
end

ld.policy = {}
ld.trap = {}
--- 向方针/毒计中加载一张卡牌。
---@param card Card @ 要加载的卡牌
ld.addCardToPolicy = function(card)
  assert(card.class:isSubclassOf(Card))
  table.insertIfNeed(ld.policy, card)
end

ld.addCardToTrap = function(card)
  assert(card.class:isSubclassOf(Card))
  table.insertIfNeed(ld.trap, card)
end
ld.standby = {}
--注册备用装备牌
ld.addCardToStandby = function(card)
  assert(card.class:isSubclassOf(Card))
  table.insertIfNeed(ld.standby, card)
end

--判断方案区内是否有方针/毒计
ld.hasPolicyorTrap = function(target, name)
  if target:getPile("#scenario") == nil then return false end
  if name ~= "eightdiagrams" then
    if #target:getPile("#scenario") > 0 and table.find(target:getPile("#scenario"), function(id) return Fk:getCardById(id).name == "eightdiagrams" end) then
      return false
    end
  end
  if #target:getPile("#scenario") > 0 then
    return table.find(target:getPile("#scenario"), function(id) return Fk:getCardById(id).name == name end)
  end
  return false
end

--判断装备牌是否生效
ld.Equipinvoked = function(target, name)
  if target:getMark("@@armor_invalid") > 0 and Fk:cloneCard(name).sub_type == Card.SubtypeArmor then return false end
  if target:getMark("@@horse_invalid") > 0 and Fk:cloneCard(name).sub_type == Card.SubtypeOffensiveRide then return false end
  return target:getMark("equip_invalid") == 0 and not ld.hasPolicyorTrap(target, "eightdiagrams")
end

--判断备用区/六龙骖驾
ld.hasStandbyEquip = function(target, name)
  if target:getMark("equip_invalid") > 0 or ld.hasPolicyorTrap(target, "eightdiagrams") then return false end
  if target:getMark("@@armor_invalid") > 0 and Fk:cloneCard(name).sub_type == Card.SubtypeArmor then return false end
  if target:getMark("@@horse_invalid") > 0 and Fk:cloneCard(name).sub_type == Card.SubtypeOffensiveRide then return false end
  if #target:getPile("#standby") > 0 or #target:getPile("sixdragon") > 0 then
    return #table.filter(target:getPile("#standby"), function(id) return Fk:getCardById(id).name == name end) > 0 or
    #table.filter(target:getPile("sixdragon"), function(id) return Fk:getCardById(id).name == name end) > 0
  end
  return false
end

--判断方案区是否有空栏
ld.hasEmptyScenario = function(target)
  local n = 3
  if target:getMark("extra_scenario") > 0 then n = 4 end
  if target:getPile("#scenario") == nil and target:getPile("#scenario&") == nil then return true end
  return (#target:getPile("#scenario&") + #target:getPile("#scenario")) < n
end

--将一张牌置入方案区
---@param is_show boolean @ 是否正面向上，默认否
ld.enterScenario = function(self, target, id, is_show)
  local n = 3
  if target:getMark("extra_scenario") > 0 then n = 4 end
  if ld.hasEmptyScenario(target) then
    local ld_tricks = target.room:getBanner("@$tricks") or {}
    table.removeOne(ld_tricks, id)
    table.shuffle(ld_tricks)
    target.room:setBanner("@$tricks", ld_tricks)
    if is_show then
      target:addToPile("#scenario", id, true, self.name)
    else
      --target:addToPile("#scenario&", id, false, self.name)
      target.room:moveCardTo(id, Card.PlayerSpecial, target, fk.ReasonJustMove, self.name, "#scenario&", false)
    end
  elseif #target:getPile("#scenario&") > 0 or 
  #table.filter(target:getPile("#scenario"), function(id) return table.contains(target:getTableMark("invalid_replace"), id) end) < n then
    local to_discard = {}
    if #target:getPile("#scenario&") > 0 then table.insertIfNeed(to_discard, {"#scenario&", target:getPile("#scenario&")}) end
    if #target:getPile("#scenario") > 0 then table.insertIfNeed(to_discard, {"policytrap", table.filter(target:getPile("#scenario"),
      function(id) return not table.contains(target:getTableMark("invalid_replace"), id) end)}) end
    if #to_discard == 0 then     
      local ret = Fk:translate(target.general) .. Fk:translate("scenario_full")
      target.room:doBroadcastNotify("ShowToast", ret)
    end
    local card = target.room:askForCardChosen(target, target, {card_data = to_discard}, "overflow", "方案区已满！你须选择被替换的牌")
    if card ~= -1 then
      target.room:sendLog{
        type = "#replacecard",
        from = target.id,
        arg = Fk:getCardById(card):toLogString(),
        toast = true,
      }
      target.room:moveCardTo(card, Card.DiscardPile, nil, fk.ReasonJustMove, self.name)
      local ld_tricks = target.room:getBanner("@$tricks") or {}
      if table.contains(ld_tricks, id) then
        table.removeOne(ld_tricks, id)
        table.shuffle(ld_tricks)
        target.room:setBanner("@$tricks", ld_tricks)
      end
      if is_show then
        target:addToPile("#scenario", id, true, self.name)
      else
        --target:addToPile("#scenario&", id, false, self.name)
        target.room:moveCardTo(id, Card.PlayerSpecial, target, fk.ReasonJustMove, self.name, "#scenario&", false)
      end
    end
  else
    if target.room:getCardArea(id) ~= Card.Void then
      target.room:moveCardTo(id, Card.DiscardPile, nil, fk.ReasonJustMove, self.name, "", true)
    end
    local ret = Fk:translate(target.general) .. Fk:translate("scenario_full")
    target.room:doBroadcastNotify("ShowToast", ret)
  end
  ld.upgradelayer(target)
end

local scenario_visible = fk.CreateVisibilitySkill{
  name = '#scenario_visible',
  frequency = Skill.Compulsory,
  card_visible = function(self, player, card)
    if player:hasSkill(self) and Fk:currentRoom():getCardArea(card) == Card.PlayerSpecial and
    player:getPileNameOfId(card:getEffectiveId()) == "#scenario&" then
      return false
    end
  end
}

Fk:addSkill(scenario_visible)

--将一张牌置入备用区
ld.enterStandby = function(self, target, id)
  local n = 2 
  if target:getMark("extra_scenario") > 0 then n = 1 end
  if #target:getPile("#standby") < n then
  else
    local card = target.room:askForCardChosen(target, target, {
      card_data = {
        {"#standby", target:getPile("#standby") }
      }
    }, "overflow", "备用区已满！你须选择被替换的牌")
    if card ~= -1 then
      target.room:sendLog{
        type = "#replacecard",
        from = target.id,
        arg = Fk:getCardById(card):toLogString(),
        toast = true,
      }
      target.room:moveCardTo(card, Card.DiscardPile, nil, fk.ReasonJustMove, self.name)
    end
  end
  local ld_equips = target.room:getBanner("@$equips") or {}
  if table.contains(ld_equips, id) then
    table.removeOne(ld_equips, id)
    table.shuffle(ld_equips)
    target.room:setBanner("@$equips", ld_equips)
  end
  target.room:sendLog{
    type = "#moveinstandby",
    from = target.id,
    arg = Fk:getCardById(id):toLogString(),
    toast = true,
  }
  target:addToPile("#standby", id, true, self.name)
  ld.upgradelayer(target)
end

--使用备用标签的装备牌
local use_standby = fk.CreateTriggerSkill{
  name = "#use_standby",
  events = {fk.TargetConfirmed},
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return data.from == player.id and data.card.type == Card.TypeEquip and data.card:getMark("@@standby") ~= 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local toPut = room:getSubcardsByRule(data.card, { Card.Processing })
    ld.enterStandby(self, player, toPut[1])
  end,

  refresh_events = {fk.AfterCardsMove},
  can_refresh = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      if move.toArea == Card.PlayerSpecial and move.to and move.to == player.id then
        for _, info in ipairs(move.moveInfo) do
          local id = info.cardId
          if player:getPileNameOfId(id) == "#standby" and Fk:getCardById(id):getMark("@@standby") ~= 0 then
            self.cost_data = Fk:getCardById(id).name
            return true
          end
        end
      elseif move.toArea ~= Card.PlayerSpecial and move.from and move.from == player.id then
        for _, info in ipairs(move.moveInfo) do
          local id = info.cardId
          if info.fromArea == Card.PlayerSpecial and Fk:getCardById(id):getMark("@@standby") ~= 0 then
            self.cost_data = Fk:getCardById(id).name
            return true
          end
        end
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      if move.toArea == Card.PlayerSpecial and move.to == player.id then
        if self.cost_data == "boomerang" or self.cost_data == "bamboojavelin" then
          player.room:handleAddLoseSkills(player, self.cost_data .. "_skill&", nil, false)
        end
      elseif move.toArea ~= Card.PlayerSpecial and move.from == player.id then
        if self.cost_data == "boomerang" or self.cost_data == "bamboojavelin" then
          player.room:handleAddLoseSkills(player, "-" .. self.cost_data .. "_skill&", nil, false)
        end
      end
    end
  end,
}

Fk:addSkill(use_standby)

--获取方针的费用（穷举）
ld.policyCost = function(card)
  local n = 0
    if card.name == "borrowingjingzhou" then
      n = 2
    elseif card.name == "adoptstrategies" then
      n = 3
    elseif card.name == "emperor_hostage" or card.name == "flourishing" then
      n = 4
    end
  return n
end

--选择一张手牌或装备牌
ld.askForCardChosen = function(self, room, player, to)
  local cards = to:getCardIds(Player.Hand)
  if player ~= to and not to:isKongcheng() and not player:isBuddy(to) then
    cards = {}
    for i = 1, #to:getCardIds(Player.Hand), 1 do
      table.insert(cards, -1)
    end
  end
  local to_discard = {}
  if #cards ~= 0 then table.insertIfNeed(to_discard, {"$Hand", cards}) end
  if #to.player_cards[Player.Equip] ~= 0 then table.insertIfNeed(to_discard, {"equipzone", to.player_cards[Player.Equip]}) end
  if #to:getPile("#standby") ~= 0 then table.insertIfNeed(to_discard, {"#standby", to:getPile("#standby")}) end
  if #to:getPile("sixdragon") ~= 0 then table.insertIfNeed(to_discard, {"sixdragon", to:getPile("sixdragon")}) end
  if #to_discard == 0 then return nil end
  local id = room:askForCardChosen(player, to, {card_data = to_discard}, self.name)
  return id
end

--选择若干张装备牌
ld.askForEquipChosen = function(self, room, player, to, min, max)
  local to_discard = {}
  if not max then max = 1 end
  if not min then min = 1 end
  if #to.player_cards[Player.Equip] ~= 0 then table.insertIfNeed(to_discard, {"equipzone", to.player_cards[Player.Equip]}) end
  if #to:getPile("#standby") ~= 0 then table.insertIfNeed(to_discard, {"#standby", to:getPile("#standby")}) end
  if #to:getPile("sixdragon") ~= 0 then table.insertIfNeed(to_discard, {"sixdragon", to:getPile("sixdragon")}) end
  if #to_discard == 0 then return nil end
  local ids = room:askForCardsChosen(player, to, min, max, {card_data = to_discard}, self.name)
  if max == 1 then
    return ids[1]
  else
    return ids
  end
end

--从计谋区检索一张牌
ld.searchForTrickCard = function(self, room, target, name)
  local ld_tricks = room:getBanner("@$tricks") or {}
  local ids = table.filter(ld_tricks, function(id) return Fk:getCardById(id).name == name end)
  if #ids > 0 then
    local id = ids[1]
    table.removeOne(ld_tricks, id)
    table.shuffle(ld_tricks)
    room:setBanner("@$tricks", ld_tricks)
    ld.enterScenario(self, target, id, false)
  end
end

local DiscoverSkill = fk.CreateActiveSkill{
  name = "DiscoverSkill&",
  anim_type = "drawcard",
  prompt = "你可以消耗1点指令，发现一张计谋牌或装备牌",
  card_num = 0,
  target_num = 0,
  can_use = function(self, player)
    return player:getMark("instruction") > 0
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    ld.addinstruction(player, -1)
    room.logic:trigger("fk.StartDiscover", player)
    local n = 3
    if player:getMark("extradiscover") > 0 then
      n = n + player:getMark("extradiscover")
      room:setPlayerMark(player, "extradiscover", 0)
    end
    local choice = room:askForChoice(player, {"ld_trick", "equip"}, self.name)
    local spreadrumor = false
    if player:getMark("@@spreadrumor-turn") ~= 0 then
      local judge = {
        who = player,
        reason = "spreadrumor",
        pattern = ".|.|diamond,club",
      }
      room:judge(judge)
      local result = judge.card
      if result.suit == Card.Heart then
        return false
      elseif result.suit == Card.Spade then
        spreadrumor = true
      end
    end
    local showcards = {}
    local ld_tricks = room:getBanner("@$tricks") or {}
    local ld_equips = room:getBanner("@$equips") or {}
    if (choice == "ld_trick" and not spreadrumor) or (spreadrumor and choice == "equip") then
      n = math.min(#ld_tricks, n)
      --showcards = U.getRandomCards(ld_tricks, n)
      showcards = table.random(ld_tricks, n)
    elseif (choice == "equip" and not spreadrumor) or (spreadrumor and choice == "ld_trick") then
      n = math.min(#ld_equips, n)
      --showcards = U.getRandomCards(ld_equips, n)
      showcards = table.random(ld_equips, n)
    end
    local target = player
    if player:getMark("@@honey_trap-phase") ~= 0 then--美人计
       target = player:getNextAlive()
    end
    if #showcards > 0 then
      --[[local id = room:askForCardChosen(target, player, {
        card_data = {
          { self.name, showcards }
        }
      }, self.name)]]
      local get = U.askforChooseCardsAndChoice(target, showcards, {"OK"}, self.name, "请选择获得的牌")
      if #get > 0 then
        local id = get[1]
        if Fk:getCardById(id).type == Card.TypeTrick then
          ld.enterScenario(self, player, id)
          table.removeOne(showcards, id)
          room.logic:trigger("fk.EndDiscover", player, {ids = showcards})
        elseif Fk:getCardById(id).type == Card.TypeEquip then
          table.removeOne(ld_equips, id)
          table.shuffle(ld_equips)
          room:setBanner("@$equips", ld_equips)
          room:moveCardTo(id, Card.PlayerHand, player, fk.ReasonJustMove, self.name)
        end
      end
    end
  end,
}

Fk:addSkill(DiscoverSkill)

local CardReturnSkill = fk.CreateTriggerSkill{
  name = "#card_return_skill",
  priority = 5,
  mute = true,
  events = {fk.BeforeCardsMove, fk.AfterDrawPileShuffle},
  can_trigger = function(self, event, target, player, data)
    if event == fk.BeforeCardsMove then
      for _, move in ipairs(data) do
        for _, info in ipairs(move.moveInfo) do
          local card = Fk:getCardById(info.cardId)
          return ((card.type == Card.TypeTrick and card.suit ~= Card.Club) or card.type == Card.TypeEquip)
          and move.toArea == Card.DiscardPile
        end
      end
    else
      return player.seat == 1--氯之智慧
    end
  end,
  on_cost = Util.TrueFunc,
  on_trigger = function(self, event, target, player, data)
    local room = player.room
    if event == fk.BeforeCardsMove then
      local mirror_moves = {}
      local tricks = {}
      local equips = {}
      for _, move in ipairs(data) do
        if move.toArea ~= Card.Void then
          local move_info = {}
          local mirror_info = {}
          for _, info in ipairs(move.moveInfo) do
            local id = info.cardId
            local card = Fk:getCardById(id)
            if ((card.type == Card.TypeTrick and card.suit ~= Card.Club) or card.type == Card.TypeEquip) and move.toArea == Card.DiscardPile then
              table.insert(mirror_info, info)
              if card.type == Card.TypeTrick then
                table.insert(tricks, id)
              elseif card.type == Card.TypeEquip then
                table.insert(equips, id)
              end
            else
              table.insert(move_info, info)
            end
          end
          if #mirror_info > 0 then
            move.moveInfo = move_info
            local mirror_move = table.clone(move)
            mirror_move.to = nil
            mirror_move.toArea = Card.Void
            mirror_move.moveInfo = mirror_info
            table.insert(mirror_moves, mirror_move)
          end
        end
      end
      if #tricks > 0 or #equips > 0 then
        if #tricks > 0 then
          room:sendLog{ type = "returnDerivedTricks", card = tricks, }
          local ld_tricks = room:getBanner("@$tricks") or {}
          table.insertTable(ld_tricks, tricks)
          table.shuffle(ld_tricks)
          room:setBanner("@$tricks", ld_tricks)
        end
        if #equips > 0 then
          room:sendLog{ type = "returnDerivedEquips", card = equips, }
          local ld_equips = room:getBanner("@$equips") or {}
          table.insertTable(ld_equips, equips)
          table.shuffle(ld_equips)
          room:setBanner("@$equips", ld_equips)
        end
        table.insertTable(data, mirror_moves)
      end
    else
      local drawpile = room.draw_pile
      local tricks = table.filter(drawpile, function (id)
        return Fk:getCardById(id).type == Card.TypeTrick and Fk:getCardById(id).suit == Card.Club
      end)
      if #tricks > 0 then
        table.forEach(tricks, function(id) return room:setCardArea(id, Card.Void, nil) end)
        table.forEach(tricks, function(id) return table.removeOne(room.draw_pile, id) end)
        room:doBroadcastNotify("UpdateDrawPile", #room.draw_pile)
        room:sendLog{ type = "returnDerivedTricks", card = tricks, }
        local ld_tricks = room:getBanner("@$tricks") or {}
        table.insertTable(ld_tricks, tricks)
        table.shuffle(ld_tricks)
        room:setBanner("@$tricks", ld_tricks)
      end
    end
    for _, p in ipairs(room.alive_players) do
      ld.upgradelayer(p)
    end
  end,
  }

Fk:addSkill(CardReturnSkill)

local ld_prohibit_move = fk.CreateTriggerSkill{
  name = "#ld_prohibit_move",
  events = {fk.BeforeCardsMove},
  frequency = Skill.Compulsory,
  mute = true,
  priority = 8,
  can_trigger = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      if move.from == player.id and (move.moveReason == fk.ReasonDiscard or move.moveReason == fk.ReasonPrey) and move.proposer ~= player.id then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea ~= Card.PlayerHand and table.contains(player:getTableMark("holygrace"), info.cardId) then
            return true
          end
        end
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local ids = {}
    for _, move in ipairs(data) do
      if move.from == player.id and (move.moveReason == fk.ReasonDiscard or move.moveReason == fk.ReasonPrey) and move.proposer ~= player.id then
        local move_info = {}
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea ~= Card.PlayerHand and table.contains(player:getTableMark("holygrace"), info.cardId) then
            table.insert(ids, info.cardId)
          else
            table.insert(move_info, info)
          end
        end
        if #ids > 0 then
          move.moveInfo = move_info
        end
      end
    end
    if #ids > 0 then
      player.room:sendLog{
        type = "#cancelDismantle",
        card = ids,
        toast = true,
      }
    end
  end,
}

Fk:addSkill(ld_prohibit_move)

local policytrap_instructions = fk.CreateTriggerSkill{
  name = "#policytrap_instructions",
  refresh_events = {fk.AfterCardsMove},
  mute = true,
  can_refresh = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      for _, info in ipairs(move.moveInfo) do
        if (move.toArea == Card.PlayerSpecial and (player:getPileNameOfId(info.cardId) == "#scenario" or player:getPileNameOfId(info.cardId) == "#standby")) or
         info.fromArea == Card.PlayerSpecial then
          local card = Fk:getCardById(info.cardId)
          return card:getMark("@@policy") > 0 or card:getMark("@@trap") > 0 or card:getMark("@@standby") > 0
        end
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    ld.upgradelayer(player)
    --[[[local policy = player.room:getBanner("@[:]policy") or {}
    local trap = player.room:getBanner("@[:]trap") or {}
    local standby = player.room:getBanner("@[:]standby") or {}
    for _, move in ipairs(data) do
      for _, info in ipairs(move.moveInfo) do
        local card = Fk:getCardById(info.cardId)
        if card:getMark("@@policy") > 0 then
          if move.toArea == Card.PlayerSpecial then
            table.insertIfNeed(policy, card.name)
          elseif info.fromArea == Card.PlayerSpecial then
            table.removeOne(policy, card.name)
          end
          player.room:setBanner("@[:]policy", policy)
        end
        if card:getMark("@@trap") > 0 then
          if move.toArea == Card.PlayerSpecial then
            table.insertIfNeed(trap, card.name)
          elseif info.fromArea == Card.PlayerSpecial then
            table.removeOne(trap, card.name)
          end
          player.room:setBanner("@[:]trap", trap)
        end
        if card:getMark("@@standby") > 0 then
          if move.toArea == Card.PlayerSpecial then
            table.insertIfNeed(standby, card.name)
          elseif info.fromArea == Card.PlayerSpecial then
            table.removeOne(standby, card.name)
          end
          player.room:setBanner("@[:]standby", standby)
        end
      end
    end]]
  end,
}

Fk:addSkill(policytrap_instructions)

Fk:loadTranslationTable{
  ["DiscoverSkill&"] = "发现",
  [":DiscoverSkill&"] = "出牌阶段，你可消耗1点指令，发现一张计谋牌或装备牌。",
  ["#card_return_skill"] = "卡牌回收",
  ["returnDerivedTricks"] = "%card 被洗入计谋区",
  ["returnDerivedEquips"] = "%card 被洗入锻造区",
  ["#scenario&"] = "<font color=\"#98FB98\">方案区</font>",
  ["#scenario"] = "<font color=\"#FF3131\">方案区</font>",
  ["#replacecard"] = "%from 的 %arg 被替换",
  ["#throwtrick"] = "%from 的 %arg 被弃置",
  ["#hiddentrick"] = "%from 的 %arg 被暗置",
  ["scenario_full"] = "的方案区无法再置入牌了",
  ["overflow"] = "",
  ["policytrap"] = "方针毒计",
  ["#ld_prohibit_move"] = "防止移动",
  ["#cancelDismantle"] = "%card 的移动被取消",
  ["@@chained"] = "横置",
  ["@[:]policy"] = "<font color=\"#ECFFDC\">方针</font>",
  ["@[:]trap"] = "<font color=\"#BDB5D5\">毒计</font>",
  ["@[:]standby"] = "<font color=\"#F3E5AB\">备用</font>",
  ["@[lay]lay"] = "区域",
  ["#invokepolicy"] = "%from 的 %arg 效果生效",
  ["#moveinstandby"] = "%arg 被置入 %from 的备用区",
}

return ld